package com.lhz.project.system.controller.auth;

import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.lhz.common.page.ResponseObject;
import com.lhz.framework.security.annotation.IgnoreToken;
import com.lhz.project.system.model.param.base.LoginParam;
import com.lhz.project.system.model.vo.base.LoginVo;
import com.lhz.project.system.service.auth.LoginService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by LiGezZ
 * Date on 2021/5/4 13:13
 *
 * @author LiGezZ
 */
@Tag(name = "登陆管理")
@ApiSort(5)
@RestController
@RequestMapping("/login")
public class LoginController {

    @Resource
    private LoginService loginService;

    @IgnoreToken
    @PostMapping
    @Operation(summary = "登陆", description = "登陆")
    @ApiResponse(content = @Content(schema = @Schema(implementation = ResponseObject.class)))
    public ResponseObject login(@RequestBody LoginParam param) {
        LoginVo obj = loginService.login(param);
        return ResponseObject.success(obj);
    }

    @PostMapping("/out")
    @Operation(summary = "登出", description = "登出")
    @ApiResponse(content = @Content(schema = @Schema(implementation = ResponseObject.class)))
    public ResponseObject logout() {
        loginService.logout();
        return ResponseObject.success();
    }

}
